<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>东单办公系统-新增习题</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="media/layui/css/layui.css" media="all">
	<script src="media/js/jquery.min.js"></script>
</head>
<body>

<form method="post">
	<div class="layui-form-item">

		<label class="layui-form-label">类型</label>
		<div class="layui-input-inline">
			<select name="type" id="s1">

				<option value="1">基础面试</option>
				<option value="2">进阶面试</option>
				<option value="3">核心算法</option>
				<option value="4">底层原理</option>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">问题</label>
		<div class="layui-input-block">
					<textarea rows="5" cols="50" placeholder="请输入问题"
							  class="layui-textarea" name="question"></textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">答案</label>
		<div class="layui-input-block">
					<textarea rows="15" cols="50" placeholder="请输入答案"
							  class="layui-textarea" name="answer"></textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">评分</label>
		<div class="layui-input-block">
			<div class="layui-input" id="test5"></div>
			<input type="hidden" name="star" id="star">
		</div>
	</div>

	<div class="layui-form-item">
		<input style="float: right;" class="layui-btn" type="submit"
			   value="确认新增">
	</div>
</form>

	<script src="media/layui/layui.js"></script>
	<script>
		layui.use([ 'form' ], function() {
			var form = layui.form, layer = layui.layer;

			$("form").submit(function () {
				$.ajax({
					type:"post",
					url:"OaNew/savequestion.do",
					data:$("form").serialize(),
					success:function (data) {
						alert(data.msg)
					}
				})
				return false;
			})

		});
	</script>
	<script>
        layui.use(['rate'], function (obj) {
            var rate = layui.rate;
            var values = obj.star;
			console.log(values);
            //自定义文本
            rate.render({
                elem: '#test5'
                , value: values
                , text: true
                , setText: function (value) { //自定义文本的回调
                    var arrs = {
                        '1': '极差'
                        , '2': '差'
                        , '3': '中等'
                        , '4': '好'
                        , '5': '极好'
                    };
					$("#star").val(value);
                }
            })
        });
	</script>
</body>
</html>